package dkbta.ontology.elements;

import dkbta.util.Pair;

/**
 * A pair that consists of an element's type and name
 * 
 * @author Uri Kanonov
 */
public class TypedName extends Pair<ElementType, String>{
	private final int _hashCode;

	public TypedName(ElementType elementType, String elementName){
		super(elementType, elementName);
		_hashCode = (elementType.ordinal() + elementName).hashCode();
	}

	@Override
	public boolean equals(Object other){
		if (other instanceof Element){
			Element o = (Element)other;
			return o.getElementType().equals(getElementType())
					&& o.getName().equals(getName());
		}
		return super.equals(other);
	}

	@Override
	public int hashCode(){
		return _hashCode;
	}

	public ElementType getElementType(){
		return getFirst();
	}

	public String getName(){
		return getSecond();
	}
}
